using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

namespace dotahost
{
    class HostSource
    {
        public Uri uri;
        public HostSource(string url)
        {
            uri = new Uri(url);
        }

        internal string GetContent()
        {
            string respString = "";
            try
            {
                HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(uri);
                HttpWebResponse webresponse = (HttpWebResponse)webreq.GetResponse();
                Stream stream = webresponse.GetResponseStream();
                StreamReader respReader = new StreamReader(stream, Encoding.GetEncoding("GB2312"));
                respString = respReader.ReadToEnd();
            }
            catch(Exception e)
            {
                throw ( new Exception("Network error!\n Please make sure your network is ok and the WM BBS is not down."));
            }
            return respString;
        }
    }
}
